package com.cf.game.im.dao;

import com.cf.crud.mapper.BaseMapper;
import com.cf.game.im.model.ChatMsg;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * boot-awm-ChatMapper
 *
 * @author <a href="2428922347@qq.com">Zhu mingming</a>
 * @info
 * @since 2018/6/28 上午 11:06
 */
@Mapper
public interface ChatMapper extends BaseMapper<ChatMsg> {

    @Select("SELECT * FROM `chatMsg` WHERE (receive =#{receiver}  AND sender =#{sender} ) OR (receive =#{sender} AND sender =#{receiver} )")
    Page<ChatMsg> selectHistory(@Param("sender") long self, @Param("receiver") long receiver);

    @Update("update chatMsg set chatMsg = true where uinId=#{uinId}")
    void updateChatMessageRead(@Param("uinId") String uinId);
}
